package com.zrrd._12_javaSE_Plus.reflect.no_18;


/**
 * @author WanJl
 * @version 1.0
 * @title No_18
 * @description
 * @create 2023/11/18 16:42
 */
public class No_18 {
    /**
     * @param className 类名
     * @return 类对象
     * @throws Exception
     */
    public static Object createInstance(String className) throws Exception {
        //1.获取Class对象
        Class<?> clazz = Class.forName(className);
        //2.创建对象
        return clazz.newInstance();
    }

    public static void main(String[] args) throws Exception {
        Object instance = createInstance("java.util.ArrayList");
        System.out.println(instance.getClass().getName());
    }
}
